<template>
  <el-button @click="open">打开</el-button>
  <m-dialog
      title="title"
      subtitle="subtitle"
      ref="dialog"
      :confirm="confirm"
      :cancel="cancel"
      @close="onClose"
  >
    <template #default="{data}">
      {{ data }}
    </template>
  </m-dialog>

</template>
<script setup lang="ts">
import {ref} from "vue";
import {$confirm, $message} from "../../morghulis/tools/feedback.ts";

const dialog = ref()

function open() {
  const data = {name: 'lyp'}
  dialog.value.open(data, {title: 'abc', subtitle: 'bcd'})
}

function confirm(data: any, done: (v?: any) => void) {
  $confirm.success('confirm')
      .then(done)
      .finally(done)
}

function cancel(data: any, done: (v?: any) => void) {
  $confirm.warning('confirm')
      .then(done)
      .finally(done)
}

function onClose() {
  $message.info('closed')
}


</script>
